package com.kitty.game.fight.artifact.passive;

import com.kitty.game.fight.bean.Fight;
import com.kitty.game.fight.bean.FightObject;
import com.kitty.game.fight.bean.SuperBossFightObject;
import com.kitty.common.utils.SpringUtils;

/**
 * 定海珠
 */
public class PearlArtifactEffect extends ArtifactEffect {

    @Override
    public short getEffectId() {
        return 8015;
    }

    @Override
    public ArtifactType getType() {
        return ArtifactType.PEARL;
    }

    @Override
    public Boolean trigger(Fight fight, FightObject member, Object... params) {
        /**超级boss另外判断*/
        if (member.isSuperBoss()) {
            return tirggerSuperBoss(fight, member, params);
        }

        if (!checkBaseCondition(fight, member)) {
            return false;
        }
        return SpringUtils.getArtifactService().getArtifactRate(getType().getName(), member.getRole());
    }

    /**
     * 超级boss是否触发法宝
     */
    protected Boolean tirggerSuperBoss(Fight fight, FightObject member, Object... params) {
        if (!checkSuperBossBaseCondition(fight, member)) {
            return false;
        }
        SuperBossFightObject superBossObject = (SuperBossFightObject) member;
        if (fight.getRound() == superBossObject.getPearlRound()) {
            return false;
        }

        superBossObject.setPearlRound(fight.getRound());
        return true;
    }

}
